﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace HasuSLLib
{
    public struct Date
    {
        #region date fields
        DateTime _date;
        #endregion

        public Date(int year, int month, int day)
        {
            _date = new DateTime(year, month, day);
        }

        public int Day
        {
            get { return Value.Day; }
        }

        public int Month
        {
            get { return Value.Month; }
        }

        public int Year
        {
            get { return Value.Year; }
        }

        public DateTime Value
        {

            get
            {
                if (_date.Year == 1 && _date.Month == 1 && _date.Day == 1)
                    _date = new DateTime(1900, 1, 1, 0, 0, 0);

                return _date;
            }
            set
            {
                _date = value;
            }
        }

        public static  Date operator +(Date date, double value)
        {
            date.Value.AddDays(value);
            return date;
        }

        public static Date operator -(Date date, double value)
        {
            date.Value.AddDays(-value);
            return date;
        }

        public static explicit operator Date(string strval)
        {
            return new Date() { Value = DateTime.Parse(strval) };
        }

        public override string ToString()
        {
            return string.Format("{0:00}/{1:00}/{2:0000}", Day, Month, Year);
        }
        //DateTime 
    }
}
